#pragma once

/* Segment rights */
#define MODE_RX "r-x"
#define MODE_RW "rw-"

#ifndef MAX_PATH
#define MAX_PATH 4096
#endif

struct map;

struct map
{
    void       * address;
    long         size;
    char       * name;
    struct map * next;
};

typedef void * (*map_cmd)(struct map * map
                          , void * args
                          , void * last_rval
                          );


/* PROC maps light api */

void * do_with_maps(struct map * map
                    , map_cmd    cmd
                    , void     * args
                    );

struct map * parse_proc_maps(pid_t pid
                             , const char * filter_mode
                             );
void free_maps(struct map * map);

void print_map(struct map * map);
void print_maps(struct map * map);

struct map * find_first_map(struct map   * map
                            ,const char * name
                            );

struct map * find_last_map(struct map   * map
                           ,const char * name
                           );



